// 封装项目常用工具函数
// 缓存数据 获取与设置

export function setSession(name,data){
    const res=JSON.stringify(data)
    sessionStorage.setItem(name,res)
}

export function getSession(name){
    const res=sessionStorage.getItem(name)
    return JSON.parse(res)
}

export function throttle (fn, wait) {
    let previoud = 0;
    return function proxy () {
        const that = this;
        let now = +new Date();
        if (now - previoud > wait) {
            fn.apply(that, arguments);
            previoud = now;
        }
    }
}